package com.day11_IO_test;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;

/**
 * @ClassName: Demo2
 * @Author: zw
 * @Description: 出百万拳，行万里路；
 * @Create 2024/3/17-19:42
 * @Version 1.0
 */
public class Demo2 {
    public static void main(String[] args) throws UnsupportedEncodingException {
        String s = "abc";
        byte[] bt = s.getBytes();
//        System.out.println(bt);
        System.out.println(Arrays.toString(bt)); // [97, 98, 99]
        String s1 = "中";
        byte[] bt1 = s1.getBytes("GBk");
        byte[] bt2 = s1.getBytes("UTF-8");

        System.out.println(Arrays.toString(bt1)); // bgk 2个字节 [-42, -48]
        System.out.println(Arrays.toString(bt2)); // utf-8 3个字节 [-28, -72, -83]
    }
}
